package com.jiuwan.gamepass.controller;

import com.jiuwan.gamepass.dto.authDto.Result;
import com.jiuwan.gamepass.service.userImpl.SysUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @version 1.0
 * 功能目的描述 ：用于  用户的增删========>>>>>>>>>>>
 * @author： pang-yun
 * @date： 2021-06-28 14:23
 */

@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private SysUserServiceImpl sysUserService;
    //增
    @RequestMapping("/addUser")
    @ResponseBody
    public Result addUser(String username,
                          String password,
                          Integer role_id
    ){
        Result result = sysUserService.addUser(username, password, role_id);
        return result;
    }

    //删
    @RequestMapping("/deleteUser")
    @ResponseBody
    public Result deleteUser(String username){
        Result result = sysUserService.deleteUser(username);
        return result;
    }

    //改
    @RequestMapping("/updateUser")
    @ResponseBody
    public Result updateUser(String username, String password,Integer role_id){
        Result result = sysUserService.updateUser(username, password, role_id);
        return result;
    }
    //查询
    @RequestMapping("/selectByUsername")
    @ResponseBody
    public Result selectByUsername(String username){
        Result select = sysUserService.select(username);
        return select;
    }

    //查询所有用户
    @RequestMapping("selectAll")
    @ResponseBody
    public Result selectAll(){
        Result result = sysUserService.selectAll();
        return result;
    }

    //分页查询
    @RequestMapping("selectPage")
    @ResponseBody
    public Result selectPage(String username, int current, int size){
        Result result=sysUserService.selectPage(username,current,size);
        return result;
    }

}
